/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package user;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.NamedQuery;
import javax.persistence.NamedQueries;
import javax.persistence.Table;


/**
 *
 * @author Nacer Khalil
 */
@Entity
@Table(name="employee")
@NamedQueries({
@NamedQuery(name="getEmployeeByUsername",query="select e from Employee e where username= :username and password=:password"),
})

public class Employee extends User{
    
    @Column(unique=true, nullable=false)
    private String username;
    
    @Column(nullable=false)
    private String type;
    
    @Column(nullable=false)
    private String password;
    
    
    public boolean canLogin(String password)
    {
        if(this.password.compareTo(password) == 0)
            return true;
        return false;
    }

    public Employee() {
        super();
    }

    public Employee( String firstName, String lastName, String address, String phoneNumber, String username,String type, String password) {
        super(firstName, lastName, address, phoneNumber);
        this.type = type;
        this.password = password;
        this.username = username;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Employee other = (Employee) obj;
        if ((this.getType() == null) ? (other.getType() != null) : !this.type.equals(other.type)) {
            return false;
        }
        if ((this.password == null) ? (other.password != null) : !this.password.equals(other.password)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 3;
        return hash;
    }

    /**
     * @return the username
     */
    public String getUsername() {
        return username;
    }

    /**
     * @param username the username to set
     */
    public void setUsername(String username) {
        this.username = username;
    }

    /**
     * @return the type
     */
    public String getType() {
        return type;
    }

    /**
     * @param type the type to set
     */
    public void setType(String type) {
        this.type = type;
    }

    /**
     * @param password the password to set
     */
    public boolean setPassword(String password) {
        this.password = password;
        return true;
    }
    
    
    
}

